package com.cy;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@SpringBootApplication
public class ProviderApplication {
    public static void main(String[] args) {
        SpringApplication.run(ProviderApplication.class, args);
    }
    @RestController
    public class ProviderController{
        @Value("${server.port:8080}")
        private String provider;
        /**
         * 基于此方法实现字符串的回显
         * echo:回显的意思
         * rest:一种软件架构编码风格，
         * 访问：http://localhost:8081//provider/echo/nacos
         * */

        @GetMapping("/provider/echo/{msg}")
        public String doRestEcho1(@PathVariable("msg") String msg) throws InterruptedException {
            //Thread.sleep(5000);
            log.info("doRestEcho1 start {}",//{}表示占位符
                    System.currentTimeMillis());

            return provider+" say hello "+msg;
        }
    }
}
